#ifndef PUSHGATEWAY_PUSH_PHPREDIS_H
#define PUSHGATEWAY_PUSH_PHPREDIS_H

#include "php_pushgateway.h"

#include "helper.h"

// #include "/data/phpredis-4.0.0/php_redis.h"
// #include "/data/phpredis-4.0.0/common.h"
// #include "/data/phpredis-4.0.0/library.h"

using namespace std;

typedef struct {
    short gc;
    size_t len;
    char *val;
} zend_string;

typedef struct fold_item {
    zval * (*fun)(INTERNAL_FUNCTION_PARAMETERS, void *, ...);
    void *ctx;
    struct fold_item *next;
} fold_item;

/* {{{ struct RedisSock */
typedef struct {
    php_stream     *stream;
    zend_string    *host;
    short          port;
    zend_string    *auth;
    double         timeout;
    double         read_timeout;
    long           retry_interval;
    int            failed;
    int            status;
    int            persistent;
    int            watching;
    zend_string    *persistent_id;

    int            serializer;
    int            compression;
    long           dbNumber;

    zend_string    *prefix;

    short          mode;
    fold_item      *head;
    fold_item      *current;

    char           *pipeline_cmd;
    size_t         pipeline_len;

    zend_string    *err;

    zend_bool      lazy_connect;

    int            scan;

    int            readonly;
    int            tcp_keepalive;
} RedisSock;
/* }}} */

#if (PHP_MAJOR_VERSION < 7)
typedef struct {
    zend_object std;
    RedisSock *sock;
} redis_object;
#else
typedef struct {
    RedisSock *sock;
    zend_object std;
} redis_object;
#endif

void push_phpredis_handler(zend_execute_data *execute_data, long execute_micro_time, string class_name, string function_name);

#endif

